/*#include<stdio.h>
#include<stdlib.h>


#define MY_VAL "MY_VAL"

int main()
{   
    char* myval=getenv(MY_VAL);
    if(myval==NULL)
    {
        printf("It is not an env\n");
    }
    else
    {
        printf("%s=%s\n",MY_VAL,myval);
    }

    return 0;
}

int main(int argc ,char*argv[])
{
    int i=0;
    while(i<argc)
    {
        printf("argv[%d] : %s\n",i,argv[i]);
        ++i;
    }

    return 0;
}


int main(int argc ,char* argv[] , char* env[])
{
    for(;env;env++)
    {
        printf("%s\n",*env);
    }

        
    return 0;
}

#include<unistd.h>


int main() 
{
    extern char** environ;

    while(environ)
    {
        printf("%s\n",*environ);
        environ++;
    }


    return 0;
}*/


#include<stdio.h>
#include<unistd.h>


int main()
{
    int a=100;
    pid_t id=fork();
    if(id<0)
    {
        printf("fork fail");
        return 1;
    }
    //子进程
    if(id==0)
    {
        int count=5; //5秒之后修改 a 的值
        while(1)
        {
            if(count==0)
            {
                a=300;
            }
            printf("子进程：pid:%d  ppid:%d  a=%d , &a =%p\n",getpid(),getppid(),a,&a);
            sleep(1);
            count--;
        }
    }
    
    //父进程
    else 
    {
        while(1)
        {

            printf("父进程：pid:%d  ppid:%d  a=%d , &a =%p\n",getpid(),getppid(),a,&a);
            sleep(1);
        }
    }

    return 0;
}









































